<?php TPL::output('admin/global/header.tpl.htm'); ?>
<?php TPL::output('admin/global/nav_menu.tpl.htm'); ?>

<div class="aw-content-wrap">
    <div class="mod">
        <div class="mod-head">
            <h3>
				<ul class="nav nav-tabs">
					<li class="<?php if ($_GET['act'] == 'index') { ?> active<?php } ?>"><a href=""><?php _e('插件列表'); ?></a></li>
					<?php if($this->upcount>0):?>
				    <li class=""><a href="javascript:;" onclick="AWS.ajax_request(G_BASE_URL+'/admin/plugin/get_new_plugin/');"><?php _e('您有'.$this->upcount.'个新插件,点击更新'); ?></a></li>
					<?php endif;?>
				</ul>
            </h3>
        </div>

		<div class="mod-body tab-content">
			<div class="alert alert-success collapse error_message"></div>
			
			<form action="admin/ajax/save_feature_status/" method="post" id="feature_form">
			<div class="table-responsive">
			<?php if ($this->list) { ?>
				<table class="table table-striped">
					<thead>
						<tr>
							<th><?php _e('标题'); ?></th>
							<th><?php _e('标识'); ?></th>
							<th><?php _e('描述'); ?></th>
							<th><?php _e('作者'); ?></th>
							<th><?php _e('版本'); ?></th>
							<th><?php _e('操作'); ?></th>
						</tr>
					</thead>
					<tbody>
						<?php foreach ($this->list AS $key => $val) { ?>
						<tr>
							<td>
								<input type="hidden" name="feature_ids[<?php echo $val['id']; ?>]" value="<?php echo $val['id']; ?>" />
								<?php echo $val['title']; ?>
							</td>
							<td><?php echo $val['name']; ?></td>
							<td><?php echo $val['intro']; ?></td>
							<td><?php echo $val['author']; ?></td>
							<td><?php echo $val['version']; ?></td>
							<td>
								<?php if($val['state']==2){?>
								<a onclick="AWS.ajax_request(G_BASE_URL + '/admin/plugin/install/', 'addon_name=<?php echo $val['name']; ?>');" title="<?php _e('安装'); ?>" class="icon glyphicon glyphicon-download-alt md-tip"></a>
								<?php }else{?>
								<?php if($val['state']==1):?>

									<a href="admin/plugin/config/?addon_name=<?php echo $val['name']; ?>" title="<?php _e('设置'); ?>" class="icon glyphicon glyphicon-wrench md-tip"></a>
								<?php endif;?>
									
								<?php if(!in_array($val['name'],['reward'])):?>
								<?php if($val['state']==1):?>
								<a onclick="AWS.ajax_request(G_BASE_URL + '/admin/plugin/disable/', 'addon_name=<?php echo $val['name']; ?>&status=0');" title="<?php _e('禁用'); ?>" class="icon glyphicon glyphicon-lock md-tip"></a>
								<?php else:?>
								<a onclick="AWS.ajax_request(G_BASE_URL + '/admin/plugin/enable/', 'addon_name=<?php echo $val['name']; ?>&status=1');" title="<?php _e('启用'); ?>" class="icon  glyphicon glyphicon-log-in md-tip"></a>
								<?php endif;?>
								<?php endif;?>

								<a onclick="AWS.ajax_request(G_BASE_URL + '/admin/plugin/uninstall/', 'addon_name=<?php echo $val['name']; ?>');" title="<?php _e('卸载'); ?>" class="icon glyphicon glyphicon-trash md-tip"></a>

								<?php }?>
								<?php if($val['upgrade']):?>
								<a onclick="AWS.ajax_request(G_BASE_URL + '/admin/plugin/upgrade/', 'addon_name=<?php echo $val['name']; ?>&version=<?php echo $val['up_version']?>');" title="<?php _e('升级'); ?>" class="icon icon-format"></a>
								<?php endif;?>
							</td>
						</tr>
						<?php } ?>
					</tbody>
				</table>
			<?php } ?>
			</div>
			</form>
			<div class="mod-table-foot">
				<?php echo $this->pagination; ?>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
	$(document).ready(function () {
		$('input.enabled-status').on('ifChanged', function () {
			AWS.ajax_post($('#feature_form'),  AWS.ajax_processer, 'error_message');
		});
	});
</script>

<?php TPL::output('admin/global/footer.tpl.htm'); ?>